<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,javaBean.Message"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>留言板系统</title>
<%--	<meta http-equiv="X-UA-Compatible" content="IE=edge">--%>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="./css/MessageList.css">
</head>

<body>
	<section>
		<br>
		<h1>享你所想</h1>
		<div class="leave" ><a href="LeaveMessage.jsp">我要留言</a></div>
		<div class="search">
			<form action="/message_board/QueryMessageServlet" method="post">
				<input type="text" name="user_name"  class="searchInput"   placeholder="请输入用户名" >
				<button type="submit" class="searchBtn">查询留言</button><br>
			</form>
		</div>

		<%
			 ArrayList mL=(ArrayList)request.getAttribute("MessageList");
		%>
		<div class="tbl-header">
			<table cellpadding="0" cellspacing="0" border="0">
				<thead>
					<tr>
						<th style="width: 10%;">留言ID</th>
						<th style="width: 10%;">标题</th>
						<th style="width: 40%;">留言内容</th>
						<th style="width: 10%;">用户昵称</th>
						<th style="width: 10%;">操作</th>
					</tr>
				</thead>
			</table>
		</div>

		<div class="tbl-content">
			<table cellpadding="0" cellspacing="0" border="0">
				<tbody>
			<% if (mL != null){
			for (int i = 0; i < mL.size(); ++i ){
					Message message = (Message)mL.get(i);%>
					<tr>
						<td style="width: 10%;"><%= message.getmid() %></td>
						<td style="width: 10%;"><a href="/message_board/ReplyDetail?mid=<%= message.getmid() %>"><%= message.gettitle() %></td>
						<td style="width: 40%;"><%= message.getcontext() %></td>
						<td style="width: 10%;"><%= message.getUsername(message.getuserid()) %></td>
						<td style="width: 10%;">
							<%
								if(message.getuserid().equals(session.getAttribute("userid")))
								{
							%>
							<a href="/message_board/DeleteMessageServlet?mid=<%= message.getmid() %>"><button > 删除 </button></a>
							<a href="/message_board/ModifyMessageServlet?mid=<%= message.getmid() %>"><button > 修改 </button></a>
							<%}%>
						</td>
					</tr><%	} } %>
				</tbody>
			</table>
		</div>
 	</section>
<script src="./js/MessageList.js"></script>
</body>
</html>